#!/usr/bin/env bash

set -eu

while read test_dir; do
  find $test_dir -type f -name "*.xml" -print0|xargs -0 -I{} cp {} "$AGGREGATED_TEST_RESULT_DIR/"
done < <(find . -path "*/build/test-results/*" -type d -name "*UnitTest")

while read report_dir; do
  mkdir -p "$AGGREGATED_REPORT_RESULT_DIR/$report_dir"
  cp -fr $report_dir/* "$AGGREGATED_REPORT_RESULT_DIR/$report_dir/"
done < <(find . -path "*/build/reports/*" -type d -name "*UnitTest")
